package com.heima.comment.controller.v1;

import com.heima.apis.comment.CommentControllerApi;
import com.heima.comment.service.CommentService;
import com.heima.model.comment.dtos.*;
import com.heima.model.comment.pojos.ApComment;
import com.heima.model.common.dtos.ResponseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/api/v1/comment")
public class CommentController implements CommentControllerApi {
    @Autowired
    private CommentService commentService;

    @PostMapping("/save")
    @Override
    public ResponseResult saveComment(@RequestBody CommentSaveDto dto) {
        return commentService.saveComment(dto);
    }

    @PostMapping("/like")
    @Override
    public ResponseResult like(@RequestBody CommentLikeDto dto) {
        return commentService.like(dto);
    }

    @PostMapping("/load")
    @Override
    public ResponseResult findByArticleId(@RequestBody CommentDto dto) {
        return commentService.findByArticleId(dto);
    }


  /*  @GetMapping("/findCommentByAuthorId/{articleId}")
    public List<ApComment> findCommentByAuthorId(@PathVariable("articleId") Long articleId){
        return commentService.findCommentByAuthorId(articleId);
    }
*/

  @PostMapping("/list")
  public ResponseResult findByWmUser(@RequestBody CommentDto dto){
      return commentService.findByWmUser(dto);
  }


    @PostMapping("/delete")
    public ResponseResult deleteByIdAndArticleId(@RequestBody CommentDeleteDto dto) {
        return commentService.deleteByIdAndArticleId(dto);
    }


    @PostMapping("/changetop")
    public ResponseResult changeTop(@RequestBody CommentChangeTopDto dto) {
        return commentService.changeTop(dto);
    }

    @PostMapping("/wmLike")
    public ResponseResult wmLike(@RequestBody CommentLikeDto dto) {
        return commentService.wmLike(dto);
    }

}